<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Child Agents</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../../boost_asio.html" title="Boost.Asio">
<link rel="up" href="../model.html" title="Asynchronous Model">
<link rel="prev" href="associators.html" title="Associated Characteristics and Associators">
<link rel="next" href="executors.html" title="Executors">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
<td align="center"><a href="../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="associators.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../model.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../boost_asio.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="executors.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="boost_asio.overview.model.child_agents"></a><a class="link" href="child_agents.html" title="Child Agents">Child Agents</a>
</h4></div></div></div>
<p>
          The asynchronous operations within an agent may themselves be implemented
          in terms of child agents.<a href="#ftn.boost_asio.overview.model.child_agents.f0" class="footnote" name="boost_asio.overview.model.child_agents.f0"><sup class="footnote">[3]</sup></a> As far as the parent agent is concerned, it is waiting for
          the completion of a single asynchronous operation. The asynchronous operations
          that constitute the child agent run in sequence, and when the final completion
          handler runs the parent agent is resumed.
        </p>
<p>
          <span class="inlinemediaobject"><img src="../../async_child_agent_chain.png" width="802"></span>
        </p>
<p>
          As with individual asynchronous operations, the asynchronous operations
          built on child agents must release their temporary resources prior to calling
          the completion handler. We may also think of these child agents as resources
          that end their lifetimes before the completion handler is invoked.
        </p>
<p>
          When an asynchronous operation creates a child agent, it may propagate<a href="#ftn.boost_asio.overview.model.child_agents.f1" class="footnote" name="boost_asio.overview.model.child_agents.f1"><sup class="footnote">[4]</sup></a> the associated characteristics of the parent agent to the child
          agent. These associated characteristics may then be recursively propagated
          through further layers of asynchronous operations and child agents. This
          stacking of asynchronous operations replicates another property of synchronous
          operations.
        </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                  <p>
                    Property of synchronous operations
                  </p>
                </th>
<th>
                  <p>
                    Equivalent property of asynchronous operations
                  </p>
                </th>
</tr></thead>
<tbody><tr>
<td>
                  <p>
                    Compositions of synchronous operations may be refactored to use
                    child functions that run on the same thread (i.e. are simply
                    called) without altering functionality.
                  </p>
                </td>
<td>
                  <p>
                    Asynchronous agents may be refactored to use asynchronous operations
                    and child agents that share the associated characteristics of
                    the parent agent, without altering functionality.
                  </p>
                </td>
</tr></tbody>
</table></div>
<p>
          Finally, some asynchronous operations may be implemented in terms of multiple
          child agents that run concurrently. In this case, the asynchronous operation
          may choose to selectively propagate the associated characteristics of the
          parent agent.
        </p>
<div class="footnotes">
<br><hr style="width:100; text-align:left;margin-left: 0">
<div id="ftn.boost_asio.overview.model.child_agents.f0" class="footnote"><p><a href="#boost_asio.overview.model.child_agents.f0" class="para"><sup class="para">[3] </sup></a>
            In Boost.Asio these asynchronous operations are referred to as <span class="emphasis"><em>composed
            operations</em></span>.
          </p></div>
<div id="ftn.boost_asio.overview.model.child_agents.f1" class="footnote"><p><a href="#boost_asio.overview.model.child_agents.f1" class="para"><sup class="para">[4] </sup></a>
            Typically, by specialising the associator trait and forwarding to the
            outer completion handler.
          </p></div>
</div>
</div>
<div class="copyright-footer">Copyright © 2003-2025 Christopher M.
      Kohlhoff<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="associators.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../model.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../boost_asio.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="executors.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
